package com.ruoyi.depot.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.depot.domain.Receipt;
import com.ruoyi.depot.domain.DTOReceiptProducts;
import com.ruoyi.depot.domain.vo.ReceiptProductVO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 收货单Mapper接口
 * 
 * @author ruoyi
 * @date 2023-12-26
 */
@Mapper
public interface ReceiptMapper extends BaseMapper<Receipt>
{
    /**
     * 查询收货单
     * 
     * @param receiptId 收货单主键
     * @return 收货单
     */
    public Receipt selectReceiptByReceiptId(String receiptId);

    /**
     * 查询收货单列表
     * 
     * @param receipt 收货单
     * @return 收货单集合
     */
    public List<Receipt> selectReceiptList(Receipt receipt);

    /**
     * 新增收货单
     * 
     * @param receipt 收货单
     * @return 结果
     */
    public int insertReceipt(Receipt receipt);

    /**
     * 修改收货单
     * 
     * @param receipt 收货单
     * @return 结果
     */
    public int updateReceipt(Receipt receipt);

    /**
     * 删除收货单
     * 
     * @param receiptId 收货单主键
     * @return 结果
     */
    public int deleteReceiptByReceiptId(String receiptId);

    /**
     * 批量删除收货单
     * 
     * @param receiptIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteReceiptByReceiptIds(String[] receiptIds);

    /**
     * 批量删除收货商品数据单
     * 
     * @param receiptIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteReceiptProductsByReceiptIds(String[] receiptIds);
    
    /**
     * 批量新增收货单
     * 
     * @param DTOReceiptProductsList 收货单列表
     * @return 结果
     */
    public int batchReceiptProducts(List<DTOReceiptProducts> DTOReceiptProductsList);
    

    /**
     * 通过收货单主键删除收货单信息
     * 
     * @param receiptId 收货单ID
     * @return 结果
     */
    public int deleteReceiptProductsByReceiptId(@Param("receiptId") String receiptId);

    /**
     * 查询最先的
     */
    public String selectLastReceiptNumberForUpdate();

    /**
     * 查询出通知的收货量
     * @param receiptIds
     * @return
     */
    public List<DTOReceiptProducts> selectNotificationQuantity(String[] receiptIds);


    /**
     * 查询收货单明细列表
     *
     * @return 收货单集合
     */
//    @MapKey("receiptId")
    public List<DTOReceiptProducts> selectReceiptListById(@Param("list") List<String> receiptId);

    /**
     * 查询已通知量=已通知未到货数量，统计“待收货”状态的收货单。
     *
     * @return 收货单集合
     */
    public  Long selectReceiptNoticeQuantityByOrdersId(@Param("ordersId") String ordersId, @Param("productId") Long productId, @Param("gtin") String gtin);

    /**
     * 查询收货单明细列表
     * @param receiptId
     * @return 收货单集合
     */
    public List<ReceiptProductVO> selectReceiptProductNotifiedCountByReceiptId(@Param("receiptId")String receiptId);

    /**
     * 批量更新收货单
     * @param DTOReceiptProductsList 收货单列表
     * @return 结果
     */
    public int batchUpdateReceiptProducts(List<DTOReceiptProducts> DTOReceiptProductsList);

    /**
     * 批量插入收货单
     * @param receipts
     * @return
     */
    int insertReceipts(@Param("receipts") List<Receipt> receipts);

    /**
     * 检查收货单号是否已存在
     * @param code
     * @return
     */
    int checkReceiptNumberExists(@Param("receiptNumber") String code);
}
